package cn.yh.hospitalappointmentsystemdemo.config;

import cn.yh.hospitalappointmentsystemdemo.interceptor.AuthInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class AuthInterceptorConfig implements WebMvcConfigurer {
    @Autowired
    private AuthInterceptor authInterceptor;

    String[] hospitalPaths = {
            "/hospitals/list",
            "/departments/list",
            "/*.html",
            "/**/*.html",
            "/**/*.css",
            "/**/*.js",
            "/swagger-resources/**",
            "/*/api-docs",
            "/banner/**",
            "/images/**"

    };

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(authInterceptor)
                .excludePathPatterns(
                        "/user/login"
                        )
                .excludePathPatterns(hospitalPaths)
                .addPathPatterns("/**");

    }
}

